Imports VSModel

Partial Class FrontEnd_Control_HeadMeta
    Inherits System.Web.UI.UserControl
    Dim _id As Integer
    Dim _menuId As Integer
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Page.RouteData.Values("Id") <> "" Then
                _id = CType(Page.RouteData.Values("Id"), Integer)
            ElseIf Page.RouteData.Values("MenuId") <> "" Then
                _menuId = CType(Page.RouteData.Values("MenuId"), Integer)
            Else
                If Page.RouteData.Values("Id") = "" Then
                    _id = 0

                ElseIf Page.RouteData.Values("MenuId") = "" Then
                    _menuId = 0
                End If
            End If
            BindMenu()
        End If
    End Sub
    Protected Sub BindMenu()
        Using data As New VSEntities
            'lay titlepage
            'lay tilepage _menuId
            If _menuId <> 0 And _id = 0 Then
                Dim titlePage = (From t In data.Menus Where t.MenuId = _menuId Select t).FirstOrDefault
                ltrTitlePage.Text = titlePage.TitlePage
                ltrTitleFacebook.Text = "<meta property='og:title' content='" & titlePage.TitlePage & "' />"
                ltrDescription.Text = "<meta property='og:description' content='" & titlePage.Description & "' />"
            End If
            'lay titlepage Content Id
            If _id <> 0 And _menuId = 0 Then
                Dim d = (From p In data.Contents Where p.Id = _id Select p).FirstOrDefault
                ltrTitlePage.Text = d.Title
                ltrTitleFacebook.Text = "<meta property='og:title' content='" & d.Title & "' />"
                ltrDescription.Text = "<meta property='og:description' content='" & d.Description & "' />"
            End If

        End Using
    End Sub
End Class
